#################################################################
## Purpose: REPLICATION for "Criminal Victimization and Agency Attitudes in Mexico"
## Author: Cassy Dorff, 2024
## Step 1: Descriptive Data for Figure # 1 in MS 
#################################################################

rm(list=ls())
source(paste0("~/Desktop/replication/0_setup.R"))

# load the data
load(file=paste0(pathData,"1_nationalsample_data.rda"))
load(file=paste0(pathData,"2_oversample_data.rda"))

# short name
ndata <- national

# factors
levels(ndata$victim_score_combined)

# key IV
dvData = ndata %>%
  select(victim_score_combined, dv2) %>%
  count(victim_score_combined, dv2) %>%
  drop_na

dv_iv=ggplot(dvData, aes(dv2, n, fill = victim_score_combined)) +
  geom_col(stat="identity", position="dodge") +
  ylab("# of Respondents") + xlab("Agency Attitudes") + ylim(c(0,300)) +
  theme_minimal() +
  scale_fill_grey(start = 0.75, end = 0.25,
                  name  ="Direct Victimization",
                  labels=c("None", "Low-level", "High-level")) +
  theme(axis.text.x = element_text(angle = 25, hjust=1, size=10)) +
  theme_minimal() +
  theme(legend.position="bottom")


ggsave(filename = paste0(pathGraphics, "dv_figure_1.pdf"), plot = dv_iv,
       dpi=350, width = 8, height=5)
